<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="../res/css/weui.css" />
    <link rel="stylesheet" href="../res/css/weuix.css" />
	<link rel="stylesheet" href="../res/css/common.css" />
    <!-- <title>交易记录</title> -->
	<script src="../res/js/zepto.min.js"></script>
	<script src="../res/js/zepto.weui.js"></script>
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
    <script src="../res/js/vue.min.js"></script>
	<script src="../res/js/common.js?v=1"></script>

    <style>
        body{
            height: 100%;
        }
        #app{
            display: flex;
            flex-direction: column;
            align-items: stretch;
            min-height: 100%;
        }
        .top-bar{
            position: sticky;
            position: -webkit-sticky;
            top: 0;
            z-index: 9;
            height: 46px;
            box-shadow: 0 0 8px -4px #e0e0e0;
        }
        .record-list {
            overflow-y: auto;
        }
        .record-item {
            margin: 10px 15px;
            padding: 10px;
            background-color: #fff;
            border-radius: 8px;
        }

        .record-item-bottom {
            margin-top: 5px;
            display: flex;
            justify-content: space-between;
        }
        .record-item-bottom > span {
            color: #666;
        }
    </style>
</head>
<body>
    <main id="app">
        <div class="weui-btn_primary weui-header top-bar">
            <div class="weui-header-left"><a class="icon icon-109" @click="pageBack"></a></div>
            <h1 class="weui-header-title">交易记录</h1>
        </div>
        <div class="record-list" @scroll="getScroll" :style="{height: `${window.innerHeight - 46}px`}">
            <div class="record-item" v-for="item in list" :key="item.id">
                <div style="font-weight: bold;">{{item.expenseTypeName}}</div>
                <div class="record-item-bottom">
                    <span>{{item.time}}</span>
                    <div>{{item.cost}}</div>
                </div>
            </div>
        </div>
    </main>
</body>
<script>
new Vue({
    el: '#app',
    data: {
        list: [],
        params: {
            size: 10,
            current: 1
        },
        noMore: false
    },
    methods: {
        pageBack(){
            history.back()
        },
        getScroll(e) {
            let {scrollTop, clientHeight, scrollHeight} = e.target
            if (scrollTop + clientHeight >= scrollHeight) {
                if (!this.noMore) {
                    this.params.size  = this.params.size + 10
                    this.getList()
                }
            }
        },
        getList() {
            newAjaxPost('/h5/order/queryTransactionListPage', this.params,(res) => {
                let {total, list} = res.data
                if (total > this.list.length) {
                    this.list = list
                } else {
                    this.noMore = true
                }
			})
        }
    },
    mounted(){
        this.getList()
    }
})
</script>

</html>